package com.wt.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created with IDEA
 * Describe:测试数据库连接
 * Author:tianji
 * Date:2018/11/1
 * Time:10:25
 */
@Controller
public class MyController {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @RequestMapping("/list")
    @ResponseBody
    public Object getDatList(){
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList("select * from account");
        if(mapList != null && mapList.size() > 0){
            return mapList.get(0);
        }
        return " no Data";
    }
}
